SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[spTareasPorProceso]
@idProceso int
AS
SET NOCOUNT ON
Select tb_tareas.duracion, descripcion, tb_Tareas.nombre, tb_Tareas.idTarea, tb_Tareas.Nombre, t1.nombre as ant, t2.nombre as ant2, t3.nombre as post, t4.nombre as post2, t5.nombre as dev, tb_TiposDeTareas.descripcion
from tb_Tareas  left outer join tb_Tareas as t1 on (tb_Tareas.anterior = t1.idTarea) left outer join tb_Tareas as t2 on (tb_tareas.anterior2 = t2.idTarea)
left outer join tb_Tareas as t3 on (tb_Tareas.posterior = t3.idTarea) left outer join tb_Tareas as t4 on (tb_Tareas.posterior2 = t4.idTarea)
left outer join tb_Tareas as t5 on (tb_Tareas.devolucion = t5.idTarea), tb_TiposDeTareas
where tb_Tareas.Proceso = @idProceso and
tb_Tareas.Tipo = tb_TiposDeTareas.idTipoDeTarea 



/* Select tb_Tareas.nombre, tb_Tareas.idTarea, tb_Tareas.Nombre, t1.nombre as ant, t2.nombre as ant2, t3.nombre as post, t4.nombre as post2, t5.nombre as dev, tb_Procesos.Nombre, Descripcion, p1.nombre as SubProceso
from tb_Tareas, tb_Tareas as t1, tb_tareas as t2, tb_tareas as t3, tb_tareas as t4, tb_Tareas as t5 ,tb_Procesos, tb_TiposDeTareas, tb_Procesos as p1
where tb_Tareas.Proceso = @idProceso and
t1.idTarea = tb_Tareas.anterior and
t2.idTarea = tb_Tareas.anterior2 and
t3.idTarea = tb_Tareas.posterior and
t4.idTarea = tb_Tareas.posterior2 and
t5.idTarea = tb_Tareas.devolucion and
tb_Tareas.tipo = idTipoDeTarea and
tb_Tareas.SubProceso = p1.idProceso
*/
GO
